package java_io_fundamentals;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author arif
 */
public class SampleReadWriteConsole {

    public static void sampleBufferedReader() {
        System.out.println("=== using BufferedReader");
        try {
            System.out.print("insert string : ");
            BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in));
            String tempString = bufferedReader.readLine();
            System.out.println("after readline : " + tempString);
        } catch (IOException ex) {
            Logger.getLogger(SampleReadWriteConsole.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    public static void sampleScanner() {
        System.out.println("=== using Scanner");
        System.out.print("insert string : ");
        Scanner scanner = new Scanner(System.in);
        String tempString = scanner.nextLine();
        System.out.println("after readline : " + tempString);
    }

    public static void main(String args[]) {
        sampleBufferedReader();
        sampleScanner();
    }
}
